export default {
	data() {
		return {
			historylistpp: '', //品牌历史记录
			scrollTop: 0,
			Brandlist: [{
				initial: 'A',
				list: [{
						brand: '奥迪',
						bid: '9'
					},
					{
						brand: '奥迪',
						bid: '9'
					}
				]
			}],
			indexlist: [],
			typeid: '',
		};
	},
	onPageScroll(e) {
		this.scrollTop = e.scrollTop;
	},
	onLoad(typeid) {
		// this.VehicleBrands();
		this.typeid = typeid.type;
		console.log(this.Brandlist)
	},
	onShow() {
		this.getHistoryList()
	},
	methods: {
		//赋值品牌
		VehicleBrands() {
			var parmeter = {
				type: 0, //0品牌/1系列/2车子
				carid: 0, //id
			};
			Core.AjaxPost(Core.Bus.BussinesscarList, parmeter, (res) => {
				this.Brandlist = res.data.Item.BrandCarList //赋值品牌list
				this.indexlist = res.data.Item.indexlist //赋值品牌listABCDEFG
			})
		},
		//选择品牌
		searchBrand(type) {
			// 历史记录
			let arr = uni.getStorageSync('historypp') || [];
			if (arr.length < 100) {
				arr = [type].concat(arr)
				uni.setStorageSync('historypp', arr);
			} else {}
			this.getHistoryList()

			// 存储
			uni.$emit('specifAll', {
				brandlist: type
			});

			uni.navigateTo({
				url: '../chooseCarModel/chooseCarModel?brandid=' + type.bid + '&&brandname=' + encodeURIComponent(type.brand) +
					'&&type=' + this.typeid
			});
		},
		//历史搜索列表
		getHistoryList() {
			uni.getStorage({
				key: 'historypp',
				success: (res) => {
					this.historylistpp = res.data.slice(0, 5)
				}
			})
		},
	}
}
